<template>
	<view class="main">
		<view class="score-all">
			<view class="score-item" v-for="exam in rankScoreList">
				<view class="item-left">
					<p class="exam-name">{{exam.examName}}</p>
					<p class="exam-date">考试时间：{{exam.examTime}}</p>
				</view>
				<view>
					<view class="item-right">
						<p class="score-count-num">{{exam.totalScore}}</p>
						<p>总成绩</p>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {ScoreService} from "../../services/api.service";
	import {needLogin} from "../../common/utils/utils";
	export default {
		data() {
			return {
				rankScoreList: []
			}
		},
		onShow() {
			needLogin(this)
		},
		onLoad() {
			const _this = this
			uni.startPullDownRefresh({
				success() {
					_this.getRankScore()
				},
				complete() {
					uni.stopPullDownRefresh();
				}
			})
		},
		onPullDownRefresh() {
			this.getRankScore()
			uni.stopPullDownRefresh();
		},
		methods: {
			getRankScore() {
				ScoreService.getRankScore()
					.then(res => {
						if (res.code === 0) {
							this.rankScoreList = res.data.certificateScoreList
							console.log(this.rankScoreList)
						}
						console.log(res.data)
					}).catch( err=> {
						console.log(err)
					})
			}
		}
	}
</script>

<style>
.main {
	width: 100%;
}
.score-item {
	position: relative;
	height: 75px;
	background-color: #f8f8f8;
	border-radius: 10px;
	margin: 12px 6px;
	padding: 10px;
}
.item-left {
	position: absolute;
}
.score-item .exam-name {
	color: #222f69;
	font-size: 16px;
	line-height: 25px;
}
.score-item .exam-date {
	color: #878b9e;
}
.score-item .item-right {
	position: absolute;
	right: 10px;
	width: 70px;
	background-color: #f86a69;
	border-radius: 7px;
	padding: 10px 10px;
	color: white;
	text-align: center;
}
.score-item .item-right .score-count-num {
	font-size: 24px;
	line-height: 20px;
}
</style>
